<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>材料结算统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../resources/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../resources/css/style.css" media="all">
    <style>
        .layui-form-item{clear: none;}
        #form_7grid .layui-form-item .layui-inline{width: 80%!important;}
        #form_7grid .layui-form-item .layui-input-inline{width: 100%!important;}
        /*.mask{display: inline-block;}*/
        .addTo{width: 80%;height: 200px; font-size: 20px;}
        /*弹框样式区*/
        .layui-form-label{width: 100px; height: 20px;}
        .layui-form-select{width: 190px;}
        #gonghuoshijian{ width: 100%;}
        .addUser{font-size: 12px;}
        .addUser input{width: 86%;}
        .layui-form-select{width: 100%!important;}
        .layui-form-select input{width: 100%;}
        .layui-form-item{padding-left: 70px;}
        .layui-form-item .layui-input-inline{width: 50%!important;}
        .masksx{width: 800px;}
        .material{display: flex;justify-content: flex-start;margin-bottom: 8px;width: 100%; flex-wrap:wrap;}
        .material label{float: left;height: 38px;line-height: 38px; display: inline-block;width: 100px;}
        ._mater{width: 49%;margin-left: 30px;}
        .layui-form-select .layui-input{padding-right: 0;}
        ._materwarp{width: 43%;}
        .masksx .forms{padding-left: 78px;}
        .material ._mater_input{width: 10%;}
        ._mater_lab{margin:0 20px;}
        .addTo{background-color: #86B1FC;color: #FFF; width: 10px;height: 10px;display: none}
        .materialone .addTo{display:inline;}
        .mater_btn{margin: 6px 0 0 6px;}
        .material_C{width: 100px;text-align: justify;line-height: 38px;float: left;}
        .material_C:after{content:'';width: 100%;display: inline-block;}
        .materialone .mater_btn{display: none;}
        .forms{padding-top: 20px;}
        @media screen and (max-width: 768px){
            .MOVE_queryon .layui-form-item {
                width: 80%;
            }
            .layui-form-item{padding: 0;}
            .MOVE_footer{text-align: right;}
            .MOVE_footer a{color: #FFF;font-size: 20px;line-height: 30px;
                padding: 10px;background-color: #F5A721;height: 100%;position: absolute;right: 0;}
        }
        .layui-form-pane .layui-input-inline{width: 80%;}
        .masksx{height: 80%;}
        .forms{height: 90%;position: relative;}
        .mask .layui-inline{padding-left: 0;width: 100%;}
        .forms{padding-left: 0px!important; position: absolute;left: 60px;}
        .mask .forms .layui-form-item,.masktow .forms .layui-form-item{width: 32%;padding-left: 0; display:
                inline-block;}
        .mask .forms .layui-input-inline{width: 70%;}
        .mask .forms .layui-input-inline input {width: 100%!important;}
        .bixuan{left: 4px;}
        ._mater{width: 55%!important;}
        .masksx .layui-form-item{margin-bottom: 10px;}
        .layui-form-selected dl{z-index: 9999;height: 120px;}
        .material label{width: auto;padding: 0 5px;}
        ._mater{margin-left: 0;}
        .mask .cailiaos{display: none;}
        .mask .cailiaos{width: 47%!important;}
        ._mater{width: 47%!important;}
        ._materwarp input{width: 45%!important;}
        .masksx{width: 900px;}
        ._mater_lab{margin: 0;padding: 0;width: 100px; display: inline-block;!important;}
        .btn_jian,.btn_zeng{float: right;}
        .caione .btn_jian{display: none;}
        .caiones .btn_zeng{display: none;}
        .bor{width: 48%;display: inline-block;padding: 5px; border: 1px solid #EEE;}
        .masktowon{width: 900px; height: 80%;text-align: left;overflow: hidden;border-radius: 5px;position: absolute;left: 0; right: 0;top: 0;bottom: 0;margin: auto;border: 1px solid #3F3F3F;background-color: #FFF;}
        .masktowOne .btn_jian{display: none;}
        .masktowtow .btn_zeng{display: none;}
        .cor{width: 50%;display: inline-block;}


        /*弹框样式区*/
        .layui-input, .layui-textarea{width: 80%;display: inline-block;}
        .tianxie,.tianxie1,.tianxie2{display: none;}
        .caixuan{line-height: 38px;}
        .forms{left: 0;}
        .main_L,.main_C,.main_R{border: 2px solid #9d9d9d;height: 500px; border-radius: 5px; overflow: auto;}
        .main_LT,.main_CT{padding: 10px 0; }
        li:before{content: "";}
        .main ul li{height:30px; line-height: 30px; border-bottom: 1px solid #9d9d9d;text-align: center;}
        /*.main .layui-form-label{padding: 9px 0;}*/
        /*.main{margin-top: 100px;}*/
        .main .layui-card-header, .layui-colla-title{height: auto}
        .main .layui-card-body{height: 400px!important; overflow: auto;}
        #form_7grid .layui-form-item{padding-left: 0;}
        .list0 th,.list0 td{padding: 5px;margin: 0;color: #333!important;}
        /*.liston1 .yin{display: none;}*/
        /*.liston1 .yin2{display: none;}*/
        /*.liston1 .yin:nth-child(1){display: inline-block;}*/
        /*.liston1 .yin2:nth-child(1){display: inline-block;}*/


    </style>
</head>
<body>
<div class="layui-col-md12" style="margin-bottom: 20px;">
    <div class="layui-card">
        <div class="layui-card-header">添加</div>
        <div class="layui-card-body layui-row layui-col-space10">
            <form class="layui-form layui-form-pane" id="form_7grid" action="" >
                <div class="layui-form-item layui-col-xs4 layui-col-sm4 layui-col-md4">
                    <div class="layui-inline xuan">
                        <div class="layui-input-inline">
                            <select name="construction" lay-verify="required" lay-search="" lay-filter="test">
                                <option value="">请选择要操作的施工单位</option>
                                <!--<option value="1">layer</option>-->
                                <!--<option value="2">form</option>-->
                                <!--<option value="3">layim</option>-->
                                <!--<option value="4">添加</option>-->
                            </select>
                        </div>

                    </div>
                    <input type="text" name="construction" lay-verify="required" placeholder="请输入施工单位" autocomplete="off" class="layui-input tianxie">
                    <a href="###" class="xuanze">填写</a>
                </div>
                <div class="layui-form-item layui-col-xs4 layui-col-sm4 layui-col-md4">
                    <div class="layui-inline xuan1">
                        <div class="layui-input-inline">
                            <select name="project" lay-verify="required" lay-search="" lay-filter="test1">
                                <option value="">请选择要操作的项目名称</option>
                                <!--<option value="1">layer</option>-->
                                <!--<option value="2">form(ssss)</option>-->
                                <!--<option value="3">layim</option>-->
                                <!--<option value="4">添加</option>-->
                            </select>
                        </div>
                    </div>
                    <input type="text" name="project" lay-verify="required" placeholder="请输入项目名称" autocomplete="off" class="layui-input tianxie1" style="width:40%;">
                    <input type="text" name="projects" lay-verify="required" placeholder="请输入起止点" autocomplete="off" class="layui-input tianxie2" style="width:40%;">

                    <a href="###" class="xuanze1" onclick="xuanze()">填写</a>
                </div>
                <div class="layui-form-item layui-col-xs4 layui-col-sm4 layui-col-md4">
                    <button class="layui-btn layui-btn-normal" type="button" onclick="material()">材料结算添加</button>

                </div>
            </form>

        </div>
    </div>
</div>

<form class="layui-form layui-form-pane" id="form_6grid" action="" lay-filter="hetong">
    <div class="formTop layui-row">
        <div class="layui-inline layui-col-lg4 layui-col-md4 layui-col-xs6">
            <div class="layui-input-inline" style="width: 80%;">
                <input type="text" name="names" lay-verify="required" placeholder="项目名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline layui-col-lg4 layui-col-md4 layui-col-xs6">
            <div class="layui-input-inline" style="width: 80%;">
                <input type="text" name="shigong" lay-verify="required" placeholder="施工单位" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline layui-col-lg4 layui-col-md4 layui-col-xs6">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="ktime" id="test-limit3" placeholder="请输入创建开始日期">
                <div class="icons">

                </div>
            </div>
        </div>
        <div class="layui-inline layui-col-lg4 layui-col-md4 layui-col-xs6" style="margin-top: 10px;">
            <div class="layui-input-inline">
                <input type="text" class="layui-input" name="jtime" id="test-limit4" placeholder="请输入创建结束日期">
                <div class="icons">

                </div>
            </div>
        </div>
        <div style="margin-top: 48px;">
            <button class="layui-btn" type="button"  onclick="query()">查询</button>
            <button class="layui-btn layui-btn-normal" type="button"  onclick="query()">材料导出</button>
            <button class="layui-btn layui-btn-normal" type="button"  onclick="query()">材料导出</button>
            <button class="layui-btn layui-btn-normal" type="button"  onclick="query()">材料导出</button>
            <button class="layui-btn layui-btn-normal" type="button"  onclick="query()">材料导出</button>


        </div>
    </div>
</form>

<div class="main">
    <form class="layui-form layui-form-pane" id="form_8grid" action="" >
        <table class="layui-table list0">
            <thead>
            <tr>
                <th style="width: 40px;text-align: center;">
                    <input type="checkbox" name="like1[write]" lay-filter="allChoose" lay-skin="primary" title='' >       <!--checked=""   是否被选中-->
                </th>
                <th>工程名称</th><th>施工单位</th><th>材料名称</th><th>材料规格</th><th>材料数量</th><th>材料单位</th><th>不含税材料费</th><th>税额</th>
            </tr>
            </thead>
            <tbody id="t_content">

                <!--<tr>-->
                    <!--<td rowspan="3" style="width:40px;text-align: center;">-->
                        <!--<input type="checkbox" name="like1[write]" lay-filter="filter" lay-skin="primary" title='' checked="">-->
                    <!--</td>-->
                    <!--<td rowspan="3" style="text-align: center;">砼鑫测试</td><td>700mm井座</td><td>700mm</td><td>3</td><td>个</td><td>泊头市兴武铸造有限公司	</td>-->
                <!--</tr>-->
                <!--<tr>-->
                    <!--<td>700mm井座</td><td>700mm</td><td>3</td><td>个</td><td>泊头市兴武铸造有限公司	</td>-->
                <!--</tr>-->
                <!--<tr>-->
                    <!--<td>700mm井座</td><td>700mm</td><td>3</td><td>个</td><td>泊头市兴武铸造有限公司</td>-->
                <!--</tr>-->

            </tbody>

        </table>
        <div id="demo1"></div>
    </form>
</div>


<div class="mask">
    <div class="masksx erpmask">
        <div class="title"><span class="titleL">材料添加</span><span class="close">×</span></div>
        <div class="forms">
            <form class="layui-form addUser" method="post" action="">
                <div class="layui-card">
                    <div class="layui-form-item">
                        <label class="layui-form-label">施工单位<span class="maohao">：</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="shigong" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input" value="" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">项目名称<span class="maohao">：</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="xiangmu" lay-verify="required" autocomplete="off" placeholder="请输入" class="layui-input" value="" disabled="disabled">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">结算时间<span class="maohao">：</span></label>
                        <div class="layui-input-block">
                            <!--<input type="text" name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">-->
                            <input type="text" name="date" class="layui-input" lay-verify="required" id="date" placeholder="请输入开始日期">
                        </div>
                    </div>


                </div>

                <div class="layui-card caione bor">
                    <div class="layui-card-header" >
                        <button class="layui-btn layui-btn-sm btn_zeng"
                                type="button"><i class="layui-icon"></i></button>
                        <button class="layui-btn layui-btn-sm btn_jian" type="button"><i class="layui-icon"></i></button>
                    </div>
                    <div class="layui-card-body layui-row layui-col-space10">
                        <div class="layui-col-md6" style="padding: 0;height: 40px; line-height: 40px;">

                            <label class="_mater_lab" style="width: 70px;">材料名:</label>
                            <div class="layui-input-inline _mater">
                                <select name="modules"  lay-filter="xiala" lay-search="" class="modules">
                                    <option value=""> </option>
                                </select>
                                <input type="text" name="modules1" placeholder="材料名称" autocomplete="off" class="layui-input cailiaos">
                            </div>

                            <a href="###" class="caixuan">填写</a>

                        </div>
                        <div class="layui-col-md6" style="padding: 0;height: 40px;line-height: 40px;">

                            <label class="_mater_lab">材料类型:</label>
                            <div class="layui-input-inline _mater">
                                <select name="d"  lay-filter="as" lay-search="">
                                    <option value="">请选择</option>
                                    <option value="1">上覆</option>
                                    <option value="2">管材</option>
                                    <option value="3">井盖</option>
                                    <option value="4">特殊</option>
                                </select>
                            </div>

                        </div>
                        <div class="layui-col-md4">
                            <label class="_mater_lab" >规格:</label>
                            <input type="text" name="guige" lay-verify="required" placeholder="" autocomplete="off" class="layui-input _mater_input" >
                        </div>
                        <div class="layui-col-md4">
                            <label class="_mater_lab" >不含税材料费:</label>
                            <input type="number" name="shuilv" lay-verify="required" placeholder="" autocomplete="off" class="layui-input _mater_input">
                        </div>
                        <div class="layui-col-md4">
                            <label class="_mater_lab" >税额:</label>
                            <input type="number" name="yunfei" lay-verify="required" placeholder="" autocomplete="off" class="layui-input _mater_input">
                        </div>
                        <div class="layui-col-md4">
                            <label class="_mater_lab" >数量:</label>
                            <input type="number" name="num" lay-verify="required" placeholder="" autocomplete="off" class="layui-input _mater_input">
                        </div>
                        <div class="layui-col-md4">
                            <label class="_mater_lab">单位:</label>
                            <input type="text" name="cailiao" lay-verify="required" placeholder="" autocomplete="off" class="layui-input _mater_input cailiao">
                        </div>

                        <div class="layui-col-md4">
                            <label class="_mater_lab" >材料供应商:</label>
                            <input type="text" name="gongyingshang" lay-verify="required" placeholder="" autocomplete="off" class="layui-input _mater_input">
                        </div>

                    </div>
                </div>


                <input type="hidden" name="cc_UUID" value="" />
                <input type="hidden" name="sup_Code" value="" />


                <div class="_submit">
                    <button class="layui-btn layui-btn-sm  tijiao" lay-submit lay-filter="_subm">提交</button>
                    <button class="layui-btn layui-btn-sm chongzhi" type="reset">重置</button>
                </div>

            </form>

        </div>

    </div>

</div>


<script src="../resources/layui/layui.js" charset="utf-8"></script>
<script src="../resources/js/style.js"></script>
<script src="../resources/js/api.js"></script>
<script>
    function material() {
        var construction=$("[name='construction']").val();      //获取施工单位名
        var project=$("[name='project']").val();                //获取项目名称
        var ssa=$('[name="projects"]').val();
        layui.use(['form', 'layedit', 'laydate'], function() {
            if(construction==false || project==false){
                layer.msg('请检查施工单位/项目名称是否填写完整');
                return;
            };

            console.log(construction==false,project==false);
            var dizhi;
            if(!ssa){
                dizhi=project;
                ssa=qizhi;
            }else{
                dizhi=project+'('+ssa+')';
            }
            console.log(ssa,'我是ssa')
            $("[name='shigong']").val(construction);
            $("[name='xiangmu']").val(dizhi).attr({'project':project,'qizhi':ssa});


            $('.mask').show();

        });



    };
    function xuanze(name,xuan,beixuan,name1,name2) {
        $(name).click(function () {
            var _text;
            _text=$(name).text();
            if(_text=='填写'){
                $(xuan).hide().children('.layui-input-inline').children('select').attr('name',name1);
                $(beixuan).show().attr('name',name2);

                $(name).text('选')
                if(name=='.xuanze1'){
                    $('.tianxie2').show();
                }
            }else{
                $(xuan).show().children('.layui-input-inline').children('select').attr('name',name2);
                $(beixuan).hide().attr('name',name1);
                $('.tianxie2').hide().val('');
                $(beixuan).val('');
                $(name).text('填写')
            };

        });
    };
    function settlement() {
        var construction=$("[name='construction']").val();      //获取施工单位名
        var project=$("[name='project']").val();                //获取项目名称
        var qizhi=$('[name="projects"]').val();
        layui.use(['form', 'layedit', 'laydate'], function() {
//            if(construction==false || project==false){
//                layer.msg('请检查施工单位/项目名称是否填写完整');
//                return;
//            };


            console.log(construction==false,project==false);
            var dizhi;
            if(!qizhi){
                dizhi=project;
            }else{
                dizhi=project+'('+qizhi+')';
            }
            $("[name='shigong']").val(construction);
            $("[name='xiangmu']").val(dizhi);


            $('.masktow').show();

        });

    }
    function query() {
        var names=$('[name="names"]').val();
        var shigong=$('[name="shigong"]').val();
        var ktime=$('[name="ktime"]').val();
        var jtime=$('[name="jtime"]').val();
        datas(1,names,shigong,ktime,jtime)

    }


    var qizhi;

    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;


        //总页数大于页码总数
        laypage.render({
            elem: 'demo1'
            ,count: 100 //数据总数
            ,limit:10
            ,jump: function(obj, first){
                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数
                datas(obj.curr)

            }
        });




    });
    function datas(currPage,sgName,proName,beginTime,endTime) {
        layui.use(['form','laypage', 'layer'], function() {
            var form = layui.form,
                laypage = layui.laypage;
                if(!currPage){
                currPage=1;
            }
            ajaxs('/api/ld/loadMaterilaTotalForLd.do','post',{'currPage':currPage,'sgName':sgName,'proName':proName,'beginTime':beginTime,'endTime':endTime},function (data) {
                var d=data.data;
                $('.list0 tbody').html('');
                //总页数大于页码总数
                sessionStorage.nums=data.pageBean.recordCount;
                console.log(d)
                var n=0;
                var html = '';
                $(d).each(function (k,v) {

                    var money = 0;
                    for ( var i = 0;  i < v.details.length; i++){
                        html += '<tr>';
                        var vv = v.details;
                        if ( i == 0 ){
                            html += ' <td rowspan="'+vv.length+'" style="width:40px;text-align: center;"><input type="checkbox" name="like1[write]" lay-filter="filter" lay-skin="primary" title="" ></td>';
                            html += '<td rowspan="'+ vv.length +'" >'+ vv[i].proName +'</td>';
                        }
                        money+=parseFloat(parseFloat(vv[i].price_notax)+parseFloat(vv[i].price_tax)).toFixed(2)
                        html += '\n' +
                            '                <td>'+ v.sgName +'</td>\n' +
                            '                <td>'+vv[i].mat_name+'</td>\n' +
                            '                <td>'+vv[i].mat_spec+'</td>\n' +
                            '                <td>'+vv[i].mat_num+'</td>\n' +
                            '                <td>'+vv[i].mat_bit+'</td>\n' +
                            '                <td>'+vv[i].price_notax+'</td>\n' +
                            '                <td>'+vv[i].price_tax+'</td>\n' +
                            '            </tr>';
                    }
                });



                $('#t_content').append(html);
                form.render();

            })
        })
    }

    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            ,table=layui.table
            ,laypage = layui.laypage
            , laydate = layui.laydate;
        //获取已有材料信息
        ajaxs('/api/public/loadPriDropDown.do','post',{'type':'b','p':getCookie('yanzheng')},function (data) {
            console.log(data);
            var datas=data.data;
            for(var i=0;i<datas.length;i++){
                $('.modules').append('<option value="'+datas[i].mat_Name+'" cailiao="'+datas[i].mat_Bit+'" mat-type="'+datas[i].mat_Type+'" guige="'+datas[i].mat_Spec+'" shuilv="'+datas[i].mat_Tax+'" danjia="'+datas[i].mat_Price+'" yunfei="'+datas[i].mat_Freight+'">'+datas[i].mat_Name+'</option>');
            }
            _dom=$('.caione').html();

            form.render();
        });
        //获取页面下拉信息
        ajaxs('/api/ld/getLdDropDown.do','post',{'type':'a'},function (data) {
//            console.log(data);
            var d=data.data;
            $.each(d,function (k,v) {
                $('[name="construction"]').append('<option value="'+v.eppName+'" id="'+v.id+'" proName="'+v.proName+'" qizhi="'+v.sgName+'">'+v.eppName+'</option>')
                $('[name="project"]').append('<option value="'+v.proName+'"  id="'+v.id+'" eppStaend="'+v.eppStaend+'" sgName="'+v.sgName+'" eppName="'+v.eppName+'">'+v.proName+'</option>')

            });
            form.render();
        });


        datas(1)

        laypage.render({
            elem: 'demo1'
            ,count: sessionStorage.nums //数据总数
            ,limit:10
            ,jump: function(obj, first){
                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数
                datas(obj.curr)

            }
        });
        var _dom;
        //日期
        laydate.render({
            elem: '#date'
            ,type:'datetime'
        });

        $('.close').click(function () {     //遮罩层隐藏
            $('.mask').hide();
            $('.masktow').hide();
        });
        //增加材料框
        $(document).on('click','.btn_zeng',function () {
            $('.caione').after('<div class="layui-card caiones bor">'+_dom+'</div>')
            form.render();
        });
        //删除材料框
        $(document).on('click','.btn_jian',function () {
           $(this).parents('.layui-card').remove();
        });
        //增加决算框
        var htmls=$('.masktow .masktowOne').html();
        $(document).on('click','.masktowOne .btn_zeng',function () {
            $('.masktow .masktowOne').after('<div class="layui-card masktowtow cor">'+htmls+'</div>')

        });
        //前后若干天可选，这里设置不能选过去的日期      最远可选1000天之后
        panduanshijiantow('#test-limit3','#test-limit4',1000,1000,'.layui-btn-normal');     //查询 开始结束时间判断

        form.on('select(test)', function(data) {
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            var a=data.elem;
            a=$('[name="construction"]').find("option:selected").attr("proName");
            console.log(a)
            $('[name="project"]').val(a);

            qizhi=$('[name="construction"]').find("option:selected").attr("qizhi");
            form.render();

        });
        form.on('select(test1)', function(data) {
            console.log(data.elem); //得到select原始DOM对象
            console.log(data.value); //得到被选中的值
            console.log(data.othis); //得到美化后的DOM对象
            var a=data.elem;
            a=$('[name="project"]').find("option:selected").attr("eppName");
            console.log(a)
            qizhi=$('[name="project"]').find("option:selected").attr("sgname")
            $('[name="construction"]').val(a);
            form.render();
        });
        form.on('select(xiala)', function(data){
//            console.log(data.elem); //得到select原始DOM对象
//            console.log(data.value); //得到被选中的值
//            console.log(data.othis); //得到美化后的DOM对象
            var datas=data.elem;
            var danwei=$(datas).find("option:selected").attr('cailiao');
            var yunfei=$(datas).find("option:selected").attr('yunfei');
            var mats=$(datas).find("option:selected").attr('mat-type');
            var shuilv=$(datas).find("option:selected").attr('shuilv');
            var guige=$(datas).find("option:selected").attr('guige');
            var danjia=$(datas).find("option:selected").attr('danjia');

            console.log( $(datas).parents('.bor').children('.layui-card-body').children('.layui-col-md4').children('[name="cailiao"]'));
            $(datas).parents('.bor').children('.layui-card-body').children('.layui-col-md4').children('[name="cailiao"]').val(danwei);
            $(datas).parents('.bor').children('.layui-card-body').children('.layui-col-md4').children('[name="guige"]').val(guige);

            $(datas).parents('.bor').children('.layui-card-body').children('.layui-col-md4').children('[name="cailiao"]').val(danwei);
            $(datas).parents('.bor').children('.layui-card-body').children('.layui-col-md4').children('input').each(function () {
                if($(this).attr('type')!='number'){
                    if($(this).attr('name')!='gongyingshang'){
                        $(this).attr('disabled','disabled');
                    }

                }
            });

            var time = 0;

            $(datas).parents('._materwarp').next().next().attr('mat-type',mats);

            form.render();
        });


        xuanze('.xuanze','.xuan','.tianxie','construction1','construction');
        xuanze('.xuanze1','.xuan1','.tianxie1','project1','project');

        $(document).on('click','.bor .caixuan',function () {
            var _text=$(this).text();
            console.log($(this).prev())
            if(_text=='填写'){
                //lay-verify="required"
                $(this).text('选');
                $(this).prev().children('.cailiaos').show().attr({'name':'modules','lay-verify':'required'});
                $(this).prev().children('select').hide().attr('name','modules1').removeAttr('lay-verify');
                $(this).prev().children('.layui-form-select').hide()
                $(this).parents('.bor input').removeAttr('disabled');
            }else{
                $(this).text('填写')
                $(this).prev().children('.layui-form-select').show()
                $(this).prev().children('.cailiaos').hide().attr('name','modules1').removeAttr('lay-verify');
                $(this).prev().prev().children('select').show().attr({'name':'modules','lay-verify':'required'});

            }
        });


        form.on('submit(_subm)',function (data) {
            var panduans=true;
            console.log(data.field)
            var cailiao='';
            var pan=true;
            $('.bor').each(function (k,v) {
                console.log(v)
                var names,lei,gui,shui,yun,nums,dan,gong,d;
                names=$(this).children('.layui-card-body').children('.layui-col-md6').children('._mater').children('[name="modules"]').val();
                lei=$(this).children('.layui-card-body').children('.layui-col-md6').children('._mater').children('[name="d"]').val();
                if(!lei){
                    layer.msg('请检查材料类型是否已选择');
                    pan=false;
                    return;
                }

                gui=$(this).children('.layui-card-body').children('.layui-col-md4').children('[name="guige"]').val();
                shui=$(this).children('.layui-card-body').children('.layui-col-md4').children('[name="shuilv"]').val();
                yun=$(this).children('.layui-card-body').children('.layui-col-md4').children('[name="yunfei"]').val();
                nums=$(this).children('.layui-card-body').children('.layui-col-md4').children('[name="num"]').val();
                dan=$(this).children('.layui-card-body').children('.layui-col-md4').children('[name="cailiao"]').val();
                gong=$(this).children('.layui-card-body').children('.layui-col-md4').children('[name="gongyingshang"]').val();
                cailiao+=names+','+lei+','+gui+','+shui+','+yun+','+nums+','+dan+','+gong+'|';
            });



            cailiao=cailiao.substr(0,cailiao.length-1);
            console.log(cailiao)
            data.field.paramData=cailiao;
            data.field.p=getCookie('yanzheng');
            data.field.eppStaEnd=$('[name="xiangmu"]').attr('project');
            data.field.buildName=$('[name="xiangmu"]').attr('qizhi');
            data.field.eppName=$('[name="shigong"]').val();
            data.field.payTime=$('[name="date"]').val();
            if(pan){
                formAlertAjax('/api/ld/addCommon.do',data.field,'.tijiao');
            }


            return false;
        });






    })

</script>
</body>
</html>